﻿using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;
using _29通过代码添加窗体;

namespace _29通过代码添加窗体
{
    public class MyWindow :Window
    {
        internal Grid myGrid = new Grid();

        public MyWindow()
        {
            InitWindow();
            Content = myGrid;
        }

        /// <summary>
        /// 初始化窗体
        /// </summary>
        public void InitWindow()
        {
            this.myGrid.ShowGridLines = true;

            RowDefinition rowDefinition1 = new RowDefinition() { Height= GridLength.Auto };
            RowDefinition rowDefinition2 = new RowDefinition() { Height= GridLength.Auto };
            RowDefinition rowDefinition3 = new RowDefinition() { Height= GridLength.Auto };
            this.myGrid.RowDefinitions.Add(rowDefinition1);
            this.myGrid.RowDefinitions.Add(rowDefinition2);
            this.myGrid.RowDefinitions.Add(rowDefinition3);

            Label la1 = new Label() { Content = "Lable1 show!" };
            Grid.SetRow(la1, 1);
            Grid.SetColumn(la1, 0);

            Label la2 = new Label() { Content = "Lable2 show!" };
            Grid.SetRow(la2, 3);
            Grid.SetColumn(la2, 0);

            this.myGrid.Children.Add(la1);
            this.myGrid.Children.Add(la2);
        }



    }
}
